package containers;

import java.util.concurrent.CopyOnWriteArrayList;

import casino.Casino;
import casino.GameCard;
import casino.Player;
import util.CardValues;

public class Discard extends CardContainer {
	
	public Discard(Casino c){
		super(c);
	}
	
	public Discard(Casino c, Player p, int x, int y){
		super(c,p,x,y,CardValues.width,CardValues.height);
	}
	
	public void addAll(CopyOnWriteArrayList<GameCard> c){
		for(GameCard g: c){
			add(g);
		}
	}
	
	@Override
	public void lengthChange() {
		for(int i = cards.size()-1; i >= 0; i--){
			if(cards.get(i).faceUp){
				cards.get(i).flip();
			}
			cards.get(i).setPosition(x, y);
			casino.bringToFront(cards.get(i));
			cards.get(i).visible = false;
			cards.get(i).accesible = false;
		}
		for(int i = 0; i < cards.size() && i < 3; i++){
			cards.get(i).visible = true;
			cards.get(i).setPosition(x-3*i, y+3*i);
		}
	}

}
